#include <pthread.h>
#include <stdio.h>

int counter = 0; // 共享变量

void* increment(void* arg) {
	    for (int i = 0; i < 100000; i++) {
		            counter++; // 非原子操作
			        }
	        return NULL;
}

int main() {
	    pthread_t t1, t2;
	        pthread_create(&t1, NULL, increment, NULL);
		    pthread_create(&t2, NULL, increment, NULL);
		        pthread_join(t1, NULL);
			    pthread_join(t2, NULL);
			        printf("Final counter: %d (Expected: 200000)\n", counter);
				    return 0;
}
